package com.labichaoka.chaoka.ui.baseinfo.person_pip;

import com.labichaoka.chaoka.entity.BaseResponse;
import com.labichaoka.chaoka.entity.SaveInformationRequest;

/**
 * Created by ruan on 2018/8/13.
 */

public class PersonInfoPipPresenterImpl implements PersonInfoPipPresenter ,PersonInfoPipInteractor.OnSaveInformationFinishedListener{
    private PersonInfoPipInteractor interactor;
    private PersonInfoPipView view;

    public PersonInfoPipPresenterImpl(PersonInfoPipInteractor interactor, PersonInfoPipView view) {
        this.interactor = interactor;
        this.view = view;
    }

    @Override
    public void saveInformation(SaveInformationRequest request) {
        if (view!=null){
            view.showProgress();
        }
        interactor.saveInformation(request,this);
    }

    @Override
    public void onDestroy() {
        view=null;
    }

    @Override
    public void onSaveSuccessed(BaseResponse response) {
        view.showMessage(response.getMessage());
        view.hideProgress();
        view.toNext();
    }

    @Override
    public void onSaveFailed() {
        view.hideProgress();
    }
}
